home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / info / lispref.info-6 < prev    next >
Encoding:
GNU Info File  |  1995-09-01  |  47.4 KB  |  1,196 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo-1.63
  2. from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995
  12.  
  13.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  14. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  15. Copyright (C) 1995 Amdahl Corporation.  Copyright (C) 1995 Ben Wing.
  16.  
  17.    Permission is granted to make and distribute verbatim copies of this
  18. manual provided the copyright notice and this permission notice are
  19. preserved on all copies.
  20.  
  21.    Permission is granted to copy and distribute modified versions of
  22. this manual under the conditions for verbatim copying, provided that the
  23. entire resulting derived work is distributed under the terms of a
  24. permission notice identical to this one.
  25.  
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that this permission notice may be stated in a
  29. translation approved by the Foundation.
  30.  
  31.    Permission is granted to copy and distribute modified versions of
  32. this manual under the conditions for verbatim copying, provided also
  33. that the section entitled "GNU General Public License" is included
  34. exactly as in the original, and provided that the entire resulting
  35. derived work is distributed under the terms of a permission notice
  36. identical to this one.
  37.  
  38.    Permission is granted to copy and distribute translations of this
  39. manual into another language, under the above conditions for modified
  40. versions, except that the section entitled "GNU General Public License"
  41. may be included in a translation approved by the Free Software
  42. Foundation instead of in the original English.
  43.  
  44. 
  45. File: lispref.info,  Node: Association Lists,  Prev: Sets And Lists,  Up: Lists
  46.  
  47. Association Lists
  48. =================
  49.  
  50.    An "association list", or "alist" for short, records a mapping from
  51. keys to values.  It is a list of cons cells called "associations": the
  52. CAR of each cell is the "key", and the CDR is the "associated value".(1)
  53.  
  54.    Here is an example of an alist.  The key `pine' is associated with
  55. the value `cones'; the key `oak' is associated with `acorns'; and the
  56. key `maple' is associated with `seeds'.
  57.  
  58.      '((pine . cones)
  59.        (oak . acorns)
  60.        (maple . seeds))
  61.  
  62.    The associated values in an alist may be any Lisp objects; so may the
  63. keys.  For example, in the following alist, the symbol `a' is
  64. associated with the number `1', and the string `"b"' is associated with
  65. the *list* `(2 3)', which is the CDR of the alist element:
  66.  
  67.      ((a . 1) ("b" 2 3))
  68.  
  69.    Sometimes it is better to design an alist to store the associated
  70. value in the CAR of the CDR of the element.  Here is an example:
  71.  
  72.      '((rose red) (lily white) (buttercup yellow))
  73.  
  74. Here we regard `red' as the value associated with `rose'.  One
  75. advantage of this method is that you can store other related
  76. information--even a list of other items--in the CDR of the CDR.  One
  77. disadvantage is that you cannot use `rassq' (see below) to find the
  78. element containing a given value.  When neither of these considerations
  79. is important, the choice is a matter of taste, as long as you are
  80. consistent about it for any given alist.
  81.  
  82.    Note that the same alist shown above could be regarded as having the
  83. associated value in the CDR of the element; the value associated with
  84. `rose' would be the list `(red)'.
  85.  
  86.    Association lists are often used to record information that you might
  87. otherwise keep on a stack, since new associations may be added easily to
  88. the front of the list.  When searching an association list for an
  89. association with a given key, the first one found is returned, if there
  90. is more than one.
  91.  
  92.    In Emacs Lisp, it is *not* an error if an element of an association
  93. list is not a cons cell.  The alist search functions simply ignore such
  94. elements.  Many other versions of Lisp signal errors in such cases.
  95.  
  96.    Note that property lists are similar to association lists in several
  97. respects.  A property list behaves like an association list in which
  98. each key can occur only once.  *Note Property Lists::, for a comparison
  99. of property lists and association lists.
  100.  
  101.  - Function: assoc KEY ALIST
  102.      This function returns the first association for KEY in ALIST.  It
  103.      compares KEY against the alist elements using `equal' (*note
  104.      Equality Predicates::.).  It returns `nil' if no association in
  105.      ALIST has a CAR `equal' to KEY.  For example:
  106.  
  107.           (setq trees '((pine . cones) (oak . acorns) (maple . seeds)))
  108.                => ((pine . cones) (oak . acorns) (maple . seeds))
  109.           (assoc 'oak trees)
  110.                => (oak . acorns)
  111.           (cdr (assoc 'oak trees))
  112.                => acorns
  113.           (assoc 'birch trees)
  114.                => nil
  115.  
  116.      Here is another example, in which the keys and values are not
  117.      symbols:
  118.  
  119.           (setq needles-per-cluster
  120.                 '((2 "Austrian Pine" "Red Pine")
  121.                   (3 "Pitch Pine")
  122.                   (5 "White Pine")))
  123.           
  124.           (cdr (assoc 3 needles-per-cluster))
  125.                => ("Pitch Pine")
  126.           (cdr (assoc 2 needles-per-cluster))
  127.                => ("Austrian Pine" "Red Pine")
  128.  
  129.  - Function: rassoc VALUE ALIST
  130.      This function returns the first association with value VALUE in
  131.      ALIST.  It returns `nil' if no association in ALIST has a CDR
  132.      `equal' to VALUE.
  133.  
  134.      `rassoc' is like `assoc' except that it compares the CDR of each
  135.      ALIST association instead of the CAR.  You can think of this as
  136.      "reverse `assoc'", finding the key for a given value.
  137.  
  138.  - Function: assq KEY ALIST
  139.      This function is like `assoc' in that it returns the first
  140.      association for KEY in ALIST, but it makes the comparison using
  141.      `eq' instead of `equal'.  `assq' returns `nil' if no association
  142.      in ALIST has a CAR `eq' to KEY.  This function is used more often
  143.      than `assoc', since `eq' is faster than `equal' and most alists
  144.      use symbols as keys.  *Note Equality Predicates::.
  145.  
  146.           (setq trees '((pine . cones) (oak . acorns) (maple . seeds)))
  147.                => ((pine . cones) (oak . acorns) (maple . seeds))
  148.           (assq 'pine trees)
  149.                => (pine . cones)
  150.  
  151.      On the other hand, `assq' is not usually useful in alists where the
  152.      keys may not be symbols:
  153.  
  154.           (setq leaves
  155.                 '(("simple leaves" . oak)
  156.                   ("compound leaves" . horsechestnut)))
  157.           
  158.           (assq "simple leaves" leaves)
  159.                => nil
  160.           (assoc "simple leaves" leaves)
  161.                => ("simple leaves" . oak)
  162.  
  163.  - Function: rassq VALUE ALIST
  164.      This function returns the first association with value VALUE in
  165.      ALIST.  It returns `nil' if no association in ALIST has a CDR `eq'
  166.      to VALUE.
  167.  
  168.      `rassq' is like `assq' except that it compares the CDR of each
  169.      ALIST association instead of the CAR.  You can think of this as
  170.      "reverse `assq'", finding the key for a given value.
  171.  
  172.      For example:
  173.  
  174.           (setq trees '((pine . cones) (oak . acorns) (maple . seeds)))
  175.           
  176.           (rassq 'acorns trees)
  177.                => (oak . acorns)
  178.           (rassq 'spores trees)
  179.                => nil
  180.  
  181.      Note that `rassq' cannot search for a value stored in the CAR of
  182.      the CDR of an element:
  183.  
  184.           (setq colors '((rose red) (lily white) (buttercup yellow)))
  185.           
  186.           (rassq 'white colors)
  187.                => nil
  188.  
  189.      In this case, the CDR of the association `(lily white)' is not the
  190.      symbol `white', but rather the list `(white)'.  This becomes
  191.      clearer if the association is written in dotted pair notation:
  192.  
  193.           (lily white) == (lily . (white))
  194.  
  195.  - Function: copy-alist ALIST
  196.      This function returns a two-level deep copy of ALIST: it creates a
  197.      new copy of each association, so that you can alter the
  198.      associations of the new alist without changing the old one.
  199.  
  200.           (setq needles-per-cluster
  201.                 '((2 . ("Austrian Pine" "Red Pine"))
  202.                   (3 . ("Pitch Pine"))
  203.                   (5 . ("White Pine"))))
  204.           =>
  205.           ((2 "Austrian Pine" "Red Pine")
  206.            (3 "Pitch Pine")
  207.            (5 "White Pine"))
  208.           
  209.           (setq copy (copy-alist needles-per-cluster))
  210.           =>
  211.           ((2 "Austrian Pine" "Red Pine")
  212.            (3 "Pitch Pine")
  213.            (5 "White Pine"))
  214.           
  215.           (eq needles-per-cluster copy)
  216.                => nil
  217.           (equal needles-per-cluster copy)
  218.                => t
  219.           (eq (car needles-per-cluster) (car copy))
  220.                => nil
  221.           (cdr (car (cdr needles-per-cluster)))
  222.                => ("Pitch Pine")
  223.           (eq (cdr (car (cdr needles-per-cluster)))
  224.               (cdr (car (cdr copy))))
  225.                => t
  226.  
  227.      This example shows how `copy-alist' makes it possible to change
  228.      the associations of one copy without affecting the other:
  229.  
  230.           (setcdr (assq 3 copy) '("Martian Vacuum Pine"))
  231.           (cdr (assq 3 needles-per-cluster))
  232.                => ("Pitch Pine")
  233.  
  234.    ---------- Footnotes ----------
  235.  
  236.    (1)  This usage of "key" is not related to the term "key sequence";
  237. it means a value used to look up an item in a table.  In this case, the
  238. table is the alist, and the alist associations are the items.
  239.  
  240. 
  241. File: lispref.info,  Node: Sequences Arrays Vectors,  Next: Symbols,  Prev: Lists,  Up: Top
  242.  
  243. Sequences, Arrays, and Vectors
  244. ******************************
  245.  
  246.    Recall that the "sequence" type is the union of three other Lisp
  247. types: lists, vectors, and strings.  In other words, any list is a
  248. sequence, any vector is a sequence, and any string is a sequence.  The
  249. common property that all sequences have is that each is an ordered
  250. collection of elements.
  251.  
  252.    An "array" is a single primitive object that has a slot for each
  253. elements.  All the elements are accessible in constant time, but the
  254. length of an existing array cannot be changed.  Strings and vectors are
  255. the two types of arrays.
  256.  
  257.    A list is a sequence of elements, but it is not a single primitive
  258. object; it is made of cons cells, one cell per element.  Finding the
  259. Nth element requires looking through N cons cells, so elements farther
  260. from the beginning of the list take longer to access.  But it is
  261. possible to add elements to the list, or remove elements.
  262.  
  263.    The following diagram shows the relationship between these types:
  264.  
  265.                ___________________________________
  266.               |                                   |
  267.               |          Sequence                 |
  268.               |  ______   ______________________  |
  269.               | |      | |                      | |
  270.               | | List | |         Array        | |
  271.               | |      | |  ________   _______  | |
  272.               | |______| | |        | |       | | |
  273.               |          | | Vector | | String| | |
  274.               |          | |________| |_______| | |
  275.               |          |______________________| |
  276.               |___________________________________|
  277.  
  278.    The elements of vectors and lists may be any Lisp objects.  The
  279. elements of strings are all characters.
  280.  
  281. * Menu:
  282.  
  283. * Sequence Functions::    Functions that accept any kind of sequence.
  284. * Arrays::                Characteristics of arrays in Emacs Lisp.
  285. * Array Functions::       Functions specifically for arrays.
  286. * Vectors::               Special characteristics of Emacs Lisp vectors.
  287. * Vector Functions::      Functions specifically for vectors.
  288.  
  289. 
  290. File: lispref.info,  Node: Sequence Functions,  Next: Arrays,  Up: Sequences Arrays Vectors
  291.  
  292. Sequences
  293. =========
  294.  
  295.    In Emacs Lisp, a "sequence" is either a list, a vector or a string.
  296. The common property that all sequences have is that each is an ordered
  297. collection of elements.  This section describes functions that accept
  298. any kind of sequence.
  299.  
  300.  - Function: sequencep OBJECT
  301.      Returns `t' if OBJECT is a list, vector, or string, `nil'
  302.      otherwise.
  303.  
  304.  - Function: copy-sequence SEQUENCE
  305.      Returns a copy of SEQUENCE.  The copy is the same type of object
  306.      as the original sequence, and it has the same elements in the same
  307.      order.
  308.  
  309.      Storing a new element into the copy does not affect the original
  310.      SEQUENCE, and vice versa.  However, the elements of the new
  311.      sequence are not copies; they are identical (`eq') to the elements
  312.      of the original.  Therefore, changes made within these elements, as
  313.      found via the copied sequence, are also visible in the original
  314.      sequence.
  315.  
  316.      If the sequence is a string with text properties, the property
  317.      list in the copy is itself a copy, not shared with the original's
  318.      property list.  However, the actual values of the properties are
  319.      shared.  *Note Text Properties::.
  320.  
  321.      See also `append' in *Note Building Lists::, `concat' in *Note
  322.      Creating Strings::, and `vconcat' in *Note Vectors::, for others
  323.      ways to copy sequences.
  324.  
  325.           (setq bar '(1 2))
  326.                => (1 2)
  327.           (setq x (vector 'foo bar))
  328.                => [foo (1 2)]
  329.           (setq y (copy-sequence x))
  330.                => [foo (1 2)]
  331.           
  332.           (eq x y)
  333.                => nil
  334.           (equal x y)
  335.                => t
  336.           (eq (elt x 1) (elt y 1))
  337.                => t
  338.           
  339.           ;; Replacing an element of one sequence.
  340.           (aset x 0 'quux)
  341.           x => [quux (1 2)]
  342.           y => [foo (1 2)]
  343.           
  344.           ;; Modifying the inside of a shared element.
  345.           (setcar (aref x 1) 69)
  346.           x => [quux (69 2)]
  347.           y => [foo (69 2)]
  348.  
  349.  - Function: length SEQUENCE
  350.      Returns the number of elements in SEQUENCE.  If SEQUENCE is a cons
  351.      cell that is not a list (because the final CDR is not `nil'), a
  352.      `wrong-type-argument' error is signaled.
  353.  
  354.           (length '(1 2 3))
  355.               => 3
  356.           (length ())
  357.               => 0
  358.           (length "foobar")
  359.               => 6
  360.           (length [1 2 3])
  361.               => 3
  362.  
  363.  - Function: elt SEQUENCE INDEX
  364.      This function returns the element of SEQUENCE indexed by INDEX.
  365.      Legitimate values of INDEX are integers ranging from 0 up to one
  366.      less than the length of SEQUENCE.  If SEQUENCE is a list, then
  367.      out-of-range values of INDEX return `nil'; otherwise, they trigger
  368.      an `args-out-of-range' error.
  369.  
  370.           (elt [1 2 3 4] 2)
  371.                => 3
  372.           (elt '(1 2 3 4) 2)
  373.                => 3
  374.           (char-to-string (elt "1234" 2))
  375.                => "3"
  376.           (elt [1 2 3 4] 4)
  377.                error-->Args out of range: [1 2 3 4], 4
  378.           (elt [1 2 3 4] -1)
  379.                error-->Args out of range: [1 2 3 4], -1
  380.  
  381.      This function generalizes `aref' (*note Array Functions::.) and
  382.      `nth' (*note List Elements::.).
  383.  
  384. 
  385. File: lispref.info,  Node: Arrays,  Next: Array Functions,  Prev: Sequence Functions,  Up: Sequences Arrays Vectors
  386.  
  387. Arrays
  388. ======
  389.  
  390.    An "array" object has slots that hold a number of other Lisp
  391. objects, called the elements of the array.  Any element of an array may
  392. be accessed in constant time.  In contrast, an element of a list
  393. requires access time that is proportional to the position of the element
  394. in the list.
  395.  
  396.    When you create an array, you must specify how many elements it has.
  397. The amount of space allocated depends on the number of elements.
  398. Therefore, it is impossible to change the size of an array once it is
  399. created; you cannot add or remove elements.  However, you can replace an
  400. element with a different value.
  401.  
  402.    XEmacs defines two types of array, both of which are one-dimensional:
  403. "strings" and "vectors".  A vector is a general array; its elements can
  404. be any Lisp objects.  A string is a specialized array; its elements
  405. must be characters (i.e., integers between 0 and 255).  Each type of
  406. array has its own read syntax.  *Note String Type::, and *Note Vector
  407. Type::.
  408.  
  409.    Both kinds of array share these characteristics:
  410.  
  411.    * The first element of an array has index zero, the second element
  412.      has index 1, and so on.  This is called "zero-origin" indexing.
  413.      For example, an array of four elements has indices 0, 1, 2, and 3.
  414.  
  415.    * The elements of an array may be referenced or changed with the
  416.      functions `aref' and `aset', respectively (*note Array
  417.      Functions::.).
  418.  
  419.    In principle, if you wish to have an array of text characters, you
  420. could use either a string or a vector.  In practice, we always choose
  421. strings for such applications, for four reasons:
  422.  
  423.    * They occupy one-fourth the space of a vector of the same elements.
  424.  
  425.    * Strings are printed in a way that shows the contents more clearly
  426.      as characters.
  427.  
  428.    * Strings can hold text properties.  *Note Text Properties::.
  429.  
  430.    * Many of the specialized editing and I/O facilities of XEmacs
  431.      accept only strings.  For example, you cannot insert a vector of
  432.      characters into a buffer the way you can insert a string.  *Note
  433.      Strings and Characters::.
  434.  
  435.    By contrast, for an array of keyboard input characters (such as a key
  436. sequence), a vector may be necessary, because many keyboard input
  437. characters are outside the range that will fit in a string.  *Note Key
  438. Sequence Input::.
  439.  
  440. 
  441. File: lispref.info,  Node: Array Functions,  Next: Vectors,  Prev: Arrays,  Up: Sequences Arrays Vectors
  442.  
  443. Functions that Operate on Arrays
  444. ================================
  445.  
  446.    In this section, we describe the functions that accept both strings
  447. and vectors.
  448.  
  449.  - Function: arrayp OBJECT
  450.      This function returns `t' if OBJECT is an array (i.e., either a
  451.      vector or a string).
  452.  
  453.           (arrayp [a])
  454.           => t
  455.           (arrayp "asdf")
  456.           => t
  457.  
  458.  - Function: aref ARRAY INDEX
  459.      This function returns the INDEXth element of ARRAY.  The first
  460.      element is at index zero.
  461.  
  462.           (setq primes [2 3 5 7 11 13])
  463.                => [2 3 5 7 11 13]
  464.           (aref primes 4)
  465.                => 11
  466.           (elt primes 4)
  467.                => 11
  468.           
  469.           (aref "abcdefg" 1)
  470.                => 98           ; `b' is ASCII code 98.
  471.  
  472.      See also the function `elt', in *Note Sequence Functions::.
  473.  
  474.  - Function: aset ARRAY INDEX OBJECT
  475.      This function sets the INDEXth element of ARRAY to be OBJECT.  It
  476.      returns OBJECT.
  477.  
  478.           (setq w [foo bar baz])
  479.                => [foo bar baz]
  480.           (aset w 0 'fu)
  481.                => fu
  482.           w
  483.                => [fu bar baz]
  484.           
  485.           (setq x "asdfasfd")
  486.                => "asdfasfd"
  487.           (aset x 3 ?Z)
  488.                => 90
  489.           x
  490.                => "asdZasfd"
  491.  
  492.      If ARRAY is a string and OBJECT is not a character, a
  493.      `wrong-type-argument' error results.
  494.  
  495.  - Function: fillarray ARRAY OBJECT
  496.      This function fills the array ARRAY with OBJECT, so that each
  497.      element of ARRAY is OBJECT.  It returns ARRAY.
  498.  
  499.           (setq a [a b c d e f g])
  500.                => [a b c d e f g]
  501.           (fillarray a 0)
  502.                => [0 0 0 0 0 0 0]
  503.           a
  504.                => [0 0 0 0 0 0 0]
  505.           (setq s "When in the course")
  506.                => "When in the course"
  507.           (fillarray s ?-)
  508.                => "------------------"
  509.  
  510.      If ARRAY is a string and OBJECT is not a character, a
  511.      `wrong-type-argument' error results.
  512.  
  513.    The general sequence functions `copy-sequence' and `length' are
  514. often useful for objects known to be arrays.  *Note Sequence
  515. Functions::.
  516.  
  517. 
  518. File: lispref.info,  Node: Vectors,  Next: Vector Functions,  Prev: Array Functions,  Up: Sequences Arrays Vectors
  519.  
  520. Vectors
  521. =======
  522.  
  523.    Arrays in Lisp, like arrays in most languages, are blocks of memory
  524. whose elements can be accessed in constant time.  A "vector" is a
  525. general-purpose array; its elements can be any Lisp objects.  (The other
  526. kind of array in Emacs Lisp is the "string", whose elements must be
  527. characters.)  Vectors in Emacs serve as syntax tables (vectors of
  528. integers), as obarrays (vectors of symbols), and in keymaps (vectors of
  529. commands).  They are also used internally as part of the representation
  530. of a byte-compiled function; if you print such a function, you will see
  531. a vector in it.
  532.  
  533.    In Emacs Lisp, the indices of the elements of a vector start from
  534. zero and count up from there.
  535.  
  536.    Vectors are printed with square brackets surrounding the elements.
  537. Thus, a vector whose elements are the symbols `a', `b' and `a' is
  538. printed as `[a b a]'.  You can write vectors in the same way in Lisp
  539. input.
  540.  
  541.    A vector, like a string or a number, is considered a constant for
  542. evaluation: the result of evaluating it is the same vector.  This does
  543. not evaluate or even examine the elements of the vector.  *Note
  544. Self-Evaluating Forms::.
  545.  
  546.    Here are examples of these principles:
  547.  
  548.      (setq avector [1 two '(three) "four" [five]])
  549.           => [1 two (quote (three)) "four" [five]]
  550.      (eval avector)
  551.           => [1 two (quote (three)) "four" [five]]
  552.      (eq avector (eval avector))
  553.           => t
  554.  
  555. 
  556. File: lispref.info,  Node: Vector Functions,  Prev: Vectors,  Up: Sequences Arrays Vectors
  557.  
  558. Functions That Operate on Vectors
  559. =================================
  560.  
  561.    Here are some functions that relate to vectors:
  562.  
  563.  - Function: vectorp OBJECT
  564.      This function returns `t' if OBJECT is a vector.
  565.  
  566.           (vectorp [a])
  567.                => t
  568.           (vectorp "asdf")
  569.                => nil
  570.  
  571.  - Function: vector &rest OBJECTS
  572.      This function creates and returns a vector whose elements are the
  573.      arguments, OBJECTS.
  574.  
  575.           (vector 'foo 23 [bar baz] "rats")
  576.                => [foo 23 [bar baz] "rats"]
  577.           (vector)
  578.                => []
  579.  
  580.  - Function: make-vector LENGTH OBJECT
  581.      This function returns a new vector consisting of LENGTH elements,
  582.      each initialized to OBJECT.
  583.  
  584.           (setq sleepy (make-vector 9 'Z))
  585.                => [Z Z Z Z Z Z Z Z Z]
  586.  
  587.  - Function: vconcat &rest SEQUENCES
  588.      This function returns a new vector containing all the elements of
  589.      the SEQUENCES.  The arguments SEQUENCES may be lists, vectors, or
  590.      strings.  If no SEQUENCES are given, an empty vector is returned.
  591.  
  592.      The value is a newly constructed vector that is not `eq' to any
  593.      existing vector.
  594.  
  595.           (setq a (vconcat '(A B C) '(D E F)))
  596.                => [A B C D E F]
  597.           (eq a (vconcat a))
  598.                => nil
  599.           (vconcat)
  600.                => []
  601.           (vconcat [A B C] "aa" '(foo (6 7)))
  602.                => [A B C 97 97 foo (6 7)]
  603.  
  604.      The `vconcat' function also allows integers as arguments.  It
  605.      converts them to strings of digits, making up the decimal print
  606.      representation of the integer, and then uses the strings instead
  607.      of the original integers.  *Don't use this feature; we plan to
  608.      eliminate it.  If you already use this feature, change your
  609.      programs now!*  The proper way to convert an integer to a decimal
  610.      number in this way is with `format' (*note Formatting Strings::.)
  611.      or `number-to-string' (*note String Conversion::.).
  612.  
  613.      For other concatenation functions, see `mapconcat' in *Note
  614.      Mapping Functions::, `concat' in *Note Creating Strings::, and
  615.      `append' in *Note Building Lists::.
  616.  
  617.    The `append' function provides a way to convert a vector into a list
  618. with the same elements (*note Building Lists::.):
  619.  
  620.      (setq avector [1 two (quote (three)) "four" [five]])
  621.           => [1 two (quote (three)) "four" [five]]
  622.      (append avector nil)
  623.           => (1 two (quote (three)) "four" [five])
  624.  
  625. 
  626. File: lispref.info,  Node: Symbols,  Next: Evaluation,  Prev: Sequences Arrays Vectors,  Up: Top
  627.  
  628. Symbols
  629. *******
  630.  
  631.    A "symbol" is an object with a unique name.  This chapter describes
  632. symbols, their components, their property lists, and how they are
  633. created and interned.  Separate chapters describe the use of symbols as
  634. variables and as function names; see *Note Variables::, and *Note
  635. Functions::.  For the precise read syntax for symbols, see *Note Symbol
  636. Type::.
  637.  
  638.    You can test whether an arbitrary Lisp object is a symbol with
  639. `symbolp':
  640.  
  641.  - Function: symbolp OBJECT
  642.      This function returns `t' if OBJECT is a symbol, `nil' otherwise.
  643.  
  644. * Menu:
  645.  
  646. * Symbol Components::        Symbols have names, values, function definitions
  647.                                and property lists.
  648. * Definitions::              A definition says how a symbol will be used.
  649. * Creating Symbols::         How symbols are kept unique.
  650. * Property Lists::           Each symbol has a property list
  651.                                for recording miscellaneous information.
  652.  
  653. 
  654. File: lispref.info,  Node: Symbol Components,  Next: Definitions,  Up: Symbols
  655.  
  656. Symbol Components
  657. =================
  658.  
  659.    Each symbol has four components (or "cells"), each of which
  660. references another object:
  661.  
  662. Print name
  663.      The "print name cell" holds a string that names the symbol for
  664.      reading and printing.  See `symbol-name' in *Note Creating
  665.      Symbols::.
  666.  
  667. Value
  668.      The "value cell" holds the current value of the symbol as a
  669.      variable.  When a symbol is used as a form, the value of the form
  670.      is the contents of the symbol's value cell.  See `symbol-value' in
  671.      *Note Accessing Variables::.
  672.  
  673. Function
  674.      The "function cell" holds the function definition of the symbol.
  675.      When a symbol is used as a function, its function definition is
  676.      used in its place.  This cell is also used to make a symbol stand
  677.      for a keymap or a keyboard macro, for editor command execution.
  678.      Because each symbol has separate value and function cells,
  679.      variables and function names do not conflict.  See
  680.      `symbol-function' in *Note Function Cells::.
  681.  
  682. Property list
  683.      The "property list cell" holds the property list of the symbol.
  684.      See `symbol-plist' in *Note Property Lists::.
  685.  
  686.    The print name cell always holds a string, and cannot be changed.
  687. The other three cells can be set individually to any specified Lisp
  688. object.
  689.  
  690.    The print name cell holds the string that is the name of the symbol.
  691. Since symbols are represented textually by their names, it is important
  692. not to have two symbols with the same name.  The Lisp reader ensures
  693. this: every time it reads a symbol, it looks for an existing symbol with
  694. the specified name before it creates a new one.  (In Emacs Lisp, this
  695. lookup uses a hashing algorithm and an obarray; see *Note Creating
  696. Symbols::.)
  697.  
  698.    In normal usage, the function cell usually contains a function or
  699. macro, as that is what the Lisp interpreter expects to see there (*note
  700. Evaluation::.).  Keyboard macros (*note Keyboard Macros::.), keymaps
  701. (*note Keymaps::.) and autoload objects (*note Autoloading::.) are also
  702. sometimes stored in the function cell of symbols.  We often refer to
  703. "the function `foo'" when we really mean the function stored in the
  704. function cell of the symbol `foo'.  We make the distinction only when
  705. necessary.
  706.  
  707.    The property list cell normally should hold a correctly formatted
  708. property list (*note Property Lists::.), as a number of functions expect
  709. to see a property list there.
  710.  
  711.    The function cell or the value cell may be "void", which means that
  712. the cell does not reference any object.  (This is not the same thing as
  713. holding the symbol `void', nor the same as holding the symbol `nil'.)
  714. Examining a cell that is void results in an error, such as `Symbol's
  715. value as variable is void'.
  716.  
  717.    The four functions `symbol-name', `symbol-value', `symbol-plist',
  718. and `symbol-function' return the contents of the four cells of a
  719. symbol.  Here as an example we show the contents of the four cells of
  720. the symbol `buffer-file-name':
  721.  
  722.      (symbol-name 'buffer-file-name)
  723.           => "buffer-file-name"
  724.      (symbol-value 'buffer-file-name)
  725.           => "/gnu/elisp/symbols.texi"
  726.      (symbol-plist 'buffer-file-name)
  727.           => (variable-documentation 29529)
  728.      (symbol-function 'buffer-file-name)
  729.           => #<subr buffer-file-name>
  730.  
  731. Because this symbol is the variable which holds the name of the file
  732. being visited in the current buffer, the value cell contents we see are
  733. the name of the source file of this chapter of the Emacs Lisp Manual.
  734. The property list cell contains the list `(variable-documentation
  735. 29529)' which tells the documentation functions where to find the
  736. documentation string for the variable `buffer-file-name' in the `DOC'
  737. file.  (29529 is the offset from the beginning of the `DOC' file to
  738. where that documentation string begins.)  The function cell contains
  739. the function for returning the name of the file.  `buffer-file-name'
  740. names a primitive function, which has no read syntax and prints in hash
  741. notation (*note Primitive Function Type::.).  A symbol naming a
  742. function written in Lisp would have a lambda expression (or a byte-code
  743. object) in this cell.
  744.  
  745. 
  746. File: lispref.info,  Node: Definitions,  Next: Creating Symbols,  Prev: Symbol Components,  Up: Symbols
  747.  
  748. Defining Symbols
  749. ================
  750.  
  751.    A "definition" in Lisp is a special form that announces your
  752. intention to use a certain symbol in a particular way.  In Emacs Lisp,
  753. you can define a symbol as a variable, or define it as a function (or
  754. macro), or both independently.
  755.  
  756.    A definition construct typically specifies a value or meaning for the
  757. symbol for one kind of use, plus documentation for its meaning when used
  758. in this way.  Thus, when you define a symbol as a variable, you can
  759. supply an initial value for the variable, plus documentation for the
  760. variable.
  761.  
  762.    `defvar' and `defconst' are special forms that define a symbol as a
  763. global variable.  They are documented in detail in *Note Defining
  764. Variables::.
  765.  
  766.    `defun' defines a symbol as a function, creating a lambda expression
  767. and storing it in the function cell of the symbol.  This lambda
  768. expression thus becomes the function definition of the symbol.  (The
  769. term "function definition", meaning the contents of the function cell,
  770. is derived from the idea that `defun' gives the symbol its definition
  771. as a function.)  `defsubst' and `defalias' are two other ways of
  772. defining a function.  *Note Functions::.
  773.  
  774.    `defmacro' defines a symbol as a macro.  It creates a macro object
  775. and stores it in the function cell of the symbol.  Note that a given
  776. symbol can be a macro or a function, but not both at once, because both
  777. macro and function definitions are kept in the function cell, and that
  778. cell can hold only one Lisp object at any given time.  *Note Macros::.
  779.  
  780.    In Emacs Lisp, a definition is not required in order to use a symbol
  781. as a variable or function.  Thus, you can make a symbol a global
  782. variable with `setq', whether you define it first or not.  The real
  783. purpose of definitions is to guide programmers and programming tools.
  784. They inform programmers who read the code that certain symbols are
  785. *intended* to be used as variables, or as functions.  In addition,
  786. utilities such as `etags' and `make-docfile' recognize definitions, and
  787. add appropriate information to tag tables and the
  788. `emacs/etc/DOC-VERSION' file. *Note Accessing Documentation::.
  789.  
  790. 
  791. File: lispref.info,  Node: Creating Symbols,  Next: Property Lists,  Prev: Definitions,  Up: Symbols
  792.  
  793. Creating and Interning Symbols
  794. ==============================
  795.  
  796.    To understand how symbols are created in XEmacs Lisp, you must know
  797. how Lisp reads them.  Lisp must ensure that it finds the same symbol
  798. every time it reads the same set of characters.  Failure to do so would
  799. cause complete confusion.
  800.  
  801.    When the Lisp reader encounters a symbol, it reads all the characters
  802. of the name.  Then it "hashes" those characters to find an index in a
  803. table called an "obarray".  Hashing is an efficient method of looking
  804. something up.  For example, instead of searching a telephone book cover
  805. to cover when looking up Jan Jones, you start with the J's and go from
  806. there.  That is a simple version of hashing.  Each element of the
  807. obarray is a "bucket" which holds all the symbols with a given hash
  808. code; to look for a given name, it is sufficient to look through all
  809. the symbols in the bucket for that name's hash code.
  810.  
  811.    If a symbol with the desired name is found, the reader uses that
  812. symbol.  If the obarray does not contain a symbol with that name, the
  813. reader makes a new symbol and adds it to the obarray.  Finding or adding
  814. a symbol with a certain name is called "interning" it, and the symbol
  815. is then called an "interned symbol".
  816.  
  817.    Interning ensures that each obarray has just one symbol with any
  818. particular name.  Other like-named symbols may exist, but not in the
  819. same obarray.  Thus, the reader gets the same symbols for the same
  820. names, as long as you keep reading with the same obarray.
  821.  
  822.    No obarray contains all symbols; in fact, some symbols are not in any
  823. obarray.  They are called "uninterned symbols".  An uninterned symbol
  824. has the same four cells as other symbols; however, the only way to gain
  825. access to it is by finding it in some other object or as the value of a
  826. variable.
  827.  
  828.    In Emacs Lisp, an obarray is actually a vector.  Each element of the
  829. vector is a bucket; its value is either an interned symbol whose name
  830. hashes to that bucket, or 0 if the bucket is empty.  Each interned
  831. symbol has an internal link (invisible to the user) to the next symbol
  832. in the bucket.  Because these links are invisible, there is no way to
  833. find all the symbols in an obarray except using `mapatoms' (below).
  834. The order of symbols in a bucket is not significant.
  835.  
  836.    In an empty obarray, every element is 0, and you can create an
  837. obarray with `(make-vector LENGTH 0)'.  *This is the only valid way to
  838. create an obarray.*  Prime numbers as lengths tend to result in good
  839. hashing; lengths one less than a power of two are also good.
  840.  
  841.    *Do not try to put symbols in an obarray yourself.*  This does not
  842. work--only `intern' can enter a symbol in an obarray properly.  *Do not
  843. try to intern one symbol in two obarrays.*  This would garble both
  844. obarrays, because a symbol has just one slot to hold the following
  845. symbol in the obarray bucket.  The results would be unpredictable.
  846.  
  847.    It is possible for two different symbols to have the same name in
  848. different obarrays; these symbols are not `eq' or `equal'.  However,
  849. this normally happens only as part of the abbrev mechanism (*note
  850. Abbrevs::.).
  851.  
  852.      Common Lisp note: In Common Lisp, a single symbol may be interned
  853.      in several obarrays.
  854.  
  855.    Most of the functions below take a name and sometimes an obarray as
  856. arguments.  A `wrong-type-argument' error is signaled if the name is
  857. not a string, or if the obarray is not a vector.
  858.  
  859.  - Function: symbol-name SYMBOL
  860.      This function returns the string that is SYMBOL's name.  For
  861.      example:
  862.  
  863.           (symbol-name 'foo)
  864.                => "foo"
  865.  
  866.      Changing the string by substituting characters, etc, does change
  867.      the name of the symbol, but fails to update the obarray, so don't
  868.      do it!
  869.  
  870.  - Function: make-symbol NAME
  871.      This function returns a newly-allocated, uninterned symbol whose
  872.      name is NAME (which must be a string).  Its value and function
  873.      definition are void, and its property list is `nil'.  In the
  874.      example below, the value of `sym' is not `eq' to `foo' because it
  875.      is a distinct uninterned symbol whose name is also `foo'.
  876.  
  877.           (setq sym (make-symbol "foo"))
  878.                => foo
  879.           (eq sym 'foo)
  880.                => nil
  881.  
  882.  - Function: intern NAME &optional OBARRAY
  883.      This function returns the interned symbol whose name is NAME.  If
  884.      there is no such symbol in the obarray OBARRAY, `intern' creates a
  885.      new one, adds it to the obarray, and returns it.  If OBARRAY is
  886.      omitted, the value of the global variable `obarray' is used.
  887.  
  888.           (setq sym (intern "foo"))
  889.                => foo
  890.           (eq sym 'foo)
  891.                => t
  892.           
  893.           (setq sym1 (intern "foo" other-obarray))
  894.                => foo
  895.           (eq sym 'foo)
  896.                => nil
  897.  
  898.  - Function: intern-soft NAME &optional OBARRAY
  899.      This function returns the symbol in OBARRAY whose name is NAME, or
  900.      `nil' if OBARRAY has no symbol with that name.  Therefore, you can
  901.      use `intern-soft' to test whether a symbol with a given name is
  902.      already interned.  If OBARRAY is omitted, the value of the global
  903.      variable `obarray' is used.
  904.  
  905.           (intern-soft "frazzle")        ; No such symbol exists.
  906.                => nil
  907.           (make-symbol "frazzle")        ; Create an uninterned one.
  908.                => frazzle
  909.           (intern-soft "frazzle")        ; That one cannot be found.
  910.                => nil
  911.  
  912.           (setq sym (intern "frazzle"))  ; Create an interned one.
  913.                => frazzle
  914.  
  915.           (intern-soft "frazzle")        ; That one can be found!
  916.                => frazzle
  917.  
  918.           (eq sym 'frazzle)              ; And it is the same one.
  919.                => t
  920.  
  921.  - Variable: obarray
  922.      This variable is the standard obarray for use by `intern' and
  923.      `read'.
  924.  
  925.  - Function: mapatoms FUNCTION &optional OBARRAY
  926.      This function calls FUNCTION for each symbol in the obarray
  927.      OBARRAY.  It returns `nil'.  If OBARRAY is omitted, it defaults to
  928.      the value of `obarray', the standard obarray for ordinary symbols.
  929.  
  930.           (setq count 0)
  931.                => 0
  932.           (defun count-syms (s)
  933.             (setq count (1+ count)))
  934.                => count-syms
  935.           (mapatoms 'count-syms)
  936.                => nil
  937.           count
  938.                => 1871
  939.  
  940.      See `documentation' in *Note Accessing Documentation::, for another
  941.      example using `mapatoms'.
  942.  
  943.  - Function: unintern SYMBOL &optional OBARRAY
  944.      This function deletes SYMBOL from the obarray OBARRAY.  If
  945.      `symbol' is not actually in the obarray, `unintern' does nothing.
  946.      If OBARRAY is `nil', the current obarray is used.
  947.  
  948.      If you provide a string instead of a symbol as SYMBOL, it stands
  949.      for a symbol name.  Then `unintern' deletes the symbol (if any) in
  950.      the obarray which has that name.  If there is no such symbol,
  951.      `unintern' does nothing.
  952.  
  953.      If `unintern' does delete a symbol, it returns `t'.  Otherwise it
  954.      returns `nil'.
  955.  
  956. 
  957. File: lispref.info,  Node: Property Lists,  Prev: Creating Symbols,  Up: Symbols
  958.  
  959. Property Lists
  960. ==============
  961.  
  962.    A "property list" ("plist" for short) is a list of paired elements
  963. stored in the property list cell of a symbol.  Each of the pairs
  964. associates a property name (usually a symbol) with a property or value.
  965. Property lists are generally used to record information about a
  966. symbol, such as its documentation as a variable, the name of the file
  967. where it was defined, or perhaps even the grammatical class of the
  968. symbol (representing a word) in a language-understanding system.
  969.  
  970.    Character positions in a string or buffer can also have property
  971. lists.  *Note Text Properties::.
  972.  
  973.    The property names and values in a property list can be any Lisp
  974. objects, but the names are usually symbols.  They are compared using
  975. `eq'.  Here is an example of a property list, found on the symbol
  976. `progn' when the compiler is loaded:
  977.  
  978.      (lisp-indent-function 0 byte-compile byte-compile-progn)
  979.  
  980. Here `lisp-indent-function' and `byte-compile' are property names, and
  981. the other two elements are the corresponding values.
  982.  
  983. * Menu:
  984.  
  985. * Plists and Alists::           Comparison of the advantages of property
  986.                                   lists and association lists.
  987. * Symbol Plists::               Functions to access symbols' property lists.
  988. * Other Plists::                Accessing property lists stored elsewhere.
  989.  
  990. 
  991. File: lispref.info,  Node: Plists and Alists,  Next: Symbol Plists,  Up: Property Lists
  992.  
  993. Property Lists and Association Lists
  994. ------------------------------------
  995.  
  996.    Association lists (*note Association Lists::.) are very similar to
  997. property lists.  In contrast to association lists, the order of the
  998. pairs in the property list is not significant since the property names
  999. must be distinct.
  1000.  
  1001.    Property lists are better than association lists for attaching
  1002. information to various Lisp function names or variables.  If all the
  1003. associations are recorded in one association list, the program will need
  1004. to search that entire list each time a function or variable is to be
  1005. operated on.  By contrast, if the information is recorded in the
  1006. property lists of the function names or variables themselves, each
  1007. search will scan only the length of one property list, which is usually
  1008. short.  This is why the documentation for a variable is recorded in a
  1009. property named `variable-documentation'.  The byte compiler likewise
  1010. uses properties to record those functions needing special treatment.
  1011.  
  1012.    However, association lists have their own advantages.  Depending on
  1013. your application, it may be faster to add an association to the front of
  1014. an association list than to update a property.  All properties for a
  1015. symbol are stored in the same property list, so there is a possibility
  1016. of a conflict between different uses of a property name.  (For this
  1017. reason, it is a good idea to choose property names that are probably
  1018. unique, such as by including the name of the library in the property
  1019. name.)  An association list may be used like a stack where associations
  1020. are pushed on the front of the list and later discarded; this is not
  1021. possible with a property list.
  1022.  
  1023. 
  1024. File: lispref.info,  Node: Symbol Plists,  Next: Other Plists,  Prev: Plists and Alists,  Up: Property Lists
  1025.  
  1026. Property List Functions for Symbols
  1027. -----------------------------------
  1028.  
  1029.  - Function: symbol-plist SYMBOL
  1030.      This function returns the property list of SYMBOL.
  1031.  
  1032.  - Function: setplist SYMBOL PLIST
  1033.      This function sets SYMBOL's property list to PLIST.  Normally,
  1034.      PLIST should be a well-formed property list, but this is not
  1035.      enforced.
  1036.  
  1037.           (setplist 'foo '(a 1 b (2 3) c nil))
  1038.                => (a 1 b (2 3) c nil)
  1039.           (symbol-plist 'foo)
  1040.                => (a 1 b (2 3) c nil)
  1041.  
  1042.      For symbols in special obarrays, which are not used for ordinary
  1043.      purposes, it may make sense to use the property list cell in a
  1044.      nonstandard fashion; in fact, the abbrev mechanism does so (*note
  1045.      Abbrevs::.).
  1046.  
  1047.  - Function: get SYMBOL PROPERTY
  1048.      This function finds the value of the property named PROPERTY in
  1049.      SYMBOL's property list.  If there is no such property, `nil' is
  1050.      returned.  Thus, there is no distinction between a value of `nil'
  1051.      and the absence of the property.
  1052.  
  1053.      The name PROPERTY is compared with the existing property names
  1054.      using `eq', so any object is a legitimate property.
  1055.  
  1056.      See `put' for an example.
  1057.  
  1058.  - Function: put SYMBOL PROPERTY VALUE
  1059.      This function puts VALUE onto SYMBOL's property list under the
  1060.      property name PROPERTY, replacing any previous property value.
  1061.      The `put' function returns VALUE.
  1062.  
  1063.           (put 'fly 'verb 'transitive)
  1064.                =>'transitive
  1065.           (put 'fly 'noun '(a buzzing little bug))
  1066.                => (a buzzing little bug)
  1067.           (get 'fly 'verb)
  1068.                => transitive
  1069.           (symbol-plist 'fly)
  1070.                => (verb transitive noun (a buzzing little bug))
  1071.  
  1072. 
  1073. File: lispref.info,  Node: Other Plists,  Prev: Symbol Plists,  Up: Property Lists
  1074.  
  1075. Property Lists Outside Symbols
  1076. ------------------------------
  1077.  
  1078.    These two functions are useful for manipulating property lists that
  1079. are stored in places other than symbols:
  1080.  
  1081.  - Function: plist-get PLIST PROPERTY
  1082.      This returns the value of the PROPERTY property stored in the
  1083.      property list PLIST.  For example,
  1084.  
  1085.           (plist-get '(foo 4) 'foo)
  1086.                => 4
  1087.  
  1088.  - Function: plist-put PLIST PROPERTY VALUE
  1089.      This stores VALUE as the value of the PROPERTY property in the
  1090.      property list PLIST.  It may modify PLIST destructively, or it may
  1091.      construct a new list structure without altering the old.  The
  1092.      function returns the modified property list, so you can store that
  1093.      back in the place where you got PLIST.  For example,
  1094.  
  1095.           (setq my-plist '(bar t foo 4))
  1096.                => (bar t foo 4)
  1097.           (setq my-plist (plist-put my-plist 'foo 69))
  1098.                => (bar t foo 69)
  1099.           (setq my-plist (plist-put my-plist 'quux '(a)))
  1100.                => (quux (a) bar t foo 5)
  1101.  
  1102. 
  1103. File: lispref.info,  Node: Evaluation,  Next: Control Structures,  Prev: Symbols,  Up: Top
  1104.  
  1105. Evaluation
  1106. **********
  1107.  
  1108.    The "evaluation" of expressions in Emacs Lisp is performed by the
  1109. "Lisp interpreter"--a program that receives a Lisp object as input and
  1110. computes its "value as an expression".  How it does this depends on the
  1111. data type of the object, according to rules described in this chapter.
  1112. The interpreter runs automatically to evaluate portions of your
  1113. program, but can also be called explicitly via the Lisp primitive
  1114. function `eval'.
  1115.  
  1116. * Menu:
  1117.  
  1118. * Intro Eval::  Evaluation in the scheme of things.
  1119. * Eval::        How to invoke the Lisp interpreter explicitly.
  1120. * Forms::       How various sorts of objects are evaluated.
  1121. * Quoting::     Avoiding evaluation (to put constants in the program).
  1122.  
  1123. 
  1124. File: lispref.info,  Node: Intro Eval,  Next: Eval,  Up: Evaluation
  1125.  
  1126. Introduction to Evaluation
  1127. ==========================
  1128.  
  1129.    The Lisp interpreter, or evaluator, is the program that computes the
  1130. value of an expression that is given to it.  When a function written in
  1131. Lisp is called, the evaluator computes the value of the function by
  1132. evaluating the expressions in the function body.  Thus, running any
  1133. Lisp program really means running the Lisp interpreter.
  1134.  
  1135.    How the evaluator handles an object depends primarily on the data
  1136. type of the object.
  1137.  
  1138.    A Lisp object that is intended for evaluation is called an
  1139. "expression" or a "form".  The fact that expressions are data objects
  1140. and not merely text is one of the fundamental differences between
  1141. Lisp-like languages and typical programming languages.  Any object can
  1142. be evaluated, but in practice only numbers, symbols, lists and strings
  1143. are evaluated very often.
  1144.  
  1145.    It is very common to read a Lisp expression and then evaluate the
  1146. expression, but reading and evaluation are separate activities, and
  1147. either can be performed alone.  Reading per se does not evaluate
  1148. anything; it converts the printed representation of a Lisp object to the
  1149. object itself.  It is up to the caller of `read' whether this object is
  1150. a form to be evaluated, or serves some entirely different purpose.
  1151. *Note Input Functions::.
  1152.  
  1153.    Do not confuse evaluation with command key interpretation.  The
  1154. editor command loop translates keyboard input into a command (an
  1155. interactively callable function) using the active keymaps, and then
  1156. uses `call-interactively' to invoke the command.  The execution of the
  1157. command itself involves evaluation if the command is written in Lisp,
  1158. but that is not a part of command key interpretation itself.  *Note
  1159. Command Loop::.
  1160.  
  1161.    Evaluation is a recursive process.  That is, evaluation of a form may
  1162. call `eval' to evaluate parts of the form.  For example, evaluation of
  1163. a function call first evaluates each argument of the function call, and
  1164. then evaluates each form in the function body.  Consider evaluation of
  1165. the form `(car x)': the subform `x' must first be evaluated
  1166. recursively, so that its value can be passed as an argument to the
  1167. function `car'.
  1168.  
  1169.    Evaluation of a function call ultimately calls the function specified
  1170. in it.  *Note Functions::.  The execution of the function may itself
  1171. work by evaluating the function definition; or the function may be a
  1172. Lisp primitive implemented in C, or it may be a byte-compiled function
  1173. (*note Byte Compilation::.).
  1174.  
  1175.    The evaluation of forms takes place in a context called the
  1176. "environment", which consists of the current values and bindings of all
  1177. Lisp variables.(1)  Whenever the form refers to a variable without
  1178. creating a new binding for it, the value of the binding in the current
  1179. environment is used.  *Note Variables::.
  1180.  
  1181.    Evaluation of a form may create new environments for recursive
  1182. evaluation by binding variables (*note Local Variables::.).  These
  1183. environments are temporary and vanish by the time evaluation of the form
  1184. is complete.  The form may also make changes that persist; these changes
  1185. are called "side effects".  An example of a form that produces side
  1186. effects is `(setq foo 1)'.
  1187.  
  1188.    The details of what evaluation means for each kind of form are
  1189. described below (*note Forms::.).
  1190.  
  1191.    ---------- Footnotes ----------
  1192.  
  1193.    (1)  This definition of "environment" is specifically not intended
  1194. to include all the data that can affect the result of a program.
  1195.  
  1196.